<extend name="template/base_index" />

<block name="area_header">
	<link rel="stylesheet" type="text/css" media="all" href="__CDN__/jquery-datetimepicker/jquery.datetimepicker.css">
	<script type="text/javascript" src="__CDN__/jquery-datetimepicker/jquery.datetimepicker.js"></script>
	<link type="text/css" rel="stylesheet" href="__CDN__/select2/4.0.0/css/select2.min.css" />
	<link type="text/css" rel="stylesheet" href="__CDN__/select2/4.0.0/css/cosmo-skin.css" />
</block>

<block name="area_body">
	{:W('Menus/topbar')}
	<div class="admin-main container-fluid">
		{:W('Menus/left')}
		<div class="admin-main-content">
			{:W('Menus/breadcrumb')}
			<!-- 过滤\查询按钮 -->
			<div class="filter-controls">
				<!-- 日期查询 -->
				<form action="{:U('Admin/Orders/returned')}" method="post" class="searchForm form-inline">
					<div class="form-group row   col-lg-12 col-md-12">
						<div class="input-group">
							<div class="input-group-addon">下单用户</div>
							<select style="width:220px;padding: 10px 15px;font-size: 15px;line-height: 1.42857143;" id="user_select2" name="uid" class="">
 <option></option>
							</select>
						</div>
						
					</div>
					<div class="form-group row col-lg-12 col-md-12">
						<div class="input-group " >

							<div class="input-group-addon">订单状态</div>
							<div class="form-control ">
								<label class="radio-inline">
									<input type="radio" name="valid_status" class="orderstatus" <eq name="valid_status" value="0">checked="checked"</eq> value="0">待审核
								</label>
								<label class="radio-inline">
									<input type="radio" name="valid_status" class="orderstatus" <eq name="valid_status" value="1">checked="checked"</eq> value="1">已退货
								</label>
								<label class="radio-inline">
									<input type="radio" name="valid_status" class="orderstatus" <eq name="valid_status" value="2">checked="checked"</eq> value="2">驳回
								</label>
								
							</div>
						</div>
					</div>
					<div class="form-group row   col-lg-12 col-md-12">
						<div class="input-group">
							<div class="input-group-addon">订单编号</div>
							<input type="text" name="order_code" placeholder="输入2015，可查询前缀为2015的订单" class="form-control" value="{$order_code}" />
							
						</div>
					
						<button type="submit" class="btn btn-default"><i class="fa fa-search"></i>{:L('BTN_SEARCH')}</button>
					</div>
				</form>
			</div>
			<!-- 操作按钮 -->
			<div class="btn-controls row col-lg-12 col-md-12">
				
			</div>
			<form action="" method="post" class="deliverForm" >
			<table class="table table-striped table table-hover  table-condensed">
				<thead>
					<tr>
						<th>
							<input type="checkbox" class="selectall" onclick="myUtils.selectall(this,'.selectitem');" />
						</th>
						<th>
							订单编号
						</th>
						<th>
							下单用户
						</th>
						<th>
							收货人
						</th>
						<th>
							联系电话
						</th>
						<th>
							总价格(元)
						</th>
						<th>
							退货原因
						</th>
						<th>
							订单状态
						</th>
						<th>
							退单时间
						</th>
						<th>
							操作
						</th>
					</tr>
				</thead>
				<tbody>
					<empty name="list">
						<tr>
							<td colspan="10" class="text-center">{:L('NO_DATA')}</td>
						</tr>
						<else/>
						<volist name="ths" id="th">
							<volist name="list" id="vo">
								<if condition="$th['order_code'] eq $vo['order_code']">
								<tr>
									<td>
										<input type="checkbox" value="{$vo.id}" name="ids[]" class="selectitem" />
									</td>
									<td>
										<a href="{:U('Admin/Orders/view',array('id'=>$vo['id']))}">{$vo.order_code}</a>
									</td>
									<td>
										{$vo.uid}
									</td>
									<td>
										{$vo.contactname}
									</td>
									<td>
										{$vo.mobile}
									</td>
									<td>
										{$vo['price']+$vo['post_price']}
									</td>
									<td>
										{$th['reason']}
									</td>
									<td>
										[{$vo.pay_status|getPayStatus}][{$vo.order_status|getOrderStatus}]
										<if condition="$th['valid_status'] eq 0">[申请待确认]</if>
										<if condition="$th['valid_status'] eq 1">[同意退货]</if>
										<if condition="$th['valid_status'] eq 2">[驳回售后][原因：{$th['reply_msg']}]</if>
									</td>
									<td>
										{$th.create_time|date='Y-m-d h:i:s',###}
									</td>
									<td>
										<a href="{:U('Admin/Orders/returnGoods',array('id'=>$vo['id'],'thid'=>$th['id']))}" 
											 class="btn btn-default btn-sm"><i class="fa fa-reply"></i>同意退货</a>	
											 <a href="{:U('Admin/Orders/returnGoodsbh',array('id'=>$vo['id'],'thid'=>$th['id']))}" 
											 class="btn btn-danger btn-sm"><i class="fa fa-reply"></i>驳回申请</a>
									</td>
								</tr>
								</if>
							</volist>
						</volist>
					</empty>
				</tbody>
			</table>
			<div>{$show}</div>
		</form>

		<script type="text/javascript">
			
			$(".orderstatus").click(function(){
				$(".searchForm").submit();
			});
			function submitForm(){
				$(".submitForm").submit();
			}
			
			$(function() {
						
			});
		</script>
	</div>
	<!-- END admin-main-content -->
	</div>
	<!-- END admin-main-->
</block>

<block name="area_footer">

	<script src="__CDN__/select2/4.0.0/js/select2.min.js"></script>
	<script src="__CDN__/select2/4.0.0/js/i18n/zh-CN.js"></script>
	<script type="text/javascript">
	$(function(){
		$("#user_select2").select2({
			placeholder: "输入用户id或昵称查询"	,
			language: "zh-CN",
			ajax: {
			    url: "{:U('Admin/Member/select')}",
			    dataType: 'json',
			    delay: 250,
			    data: function (params) {
			    	var queryParameters = {
				      q: params.term
				    }
    				return queryParameters;
			      
			    },
			    processResults: function (data, page) {
			    	if(!data.info){
			    		data.info = new Array();
			    		data.info['nodata']="无相关数据";
			    	}
			      	// parse the results into the format expected by Select2.
			      	// since we are using custom formatting functions we do not need to
			      	// alter the remote JSON data
			      	return {
			        	results: data.info
			      	};
			    },
			    cache: true
		  	}, 
			  	minimumInputLength: 0,
				templateSelection: function (repo) {	
	  				return repo.nickname || repo.text;
				},
			  templateResult: function (repo) {
			   		
      				if (repo.loading) return repo.text;
					if(repo.nodata) return repo.nodata;
//    				var markup = '<div>'+repo.nickname+'</div>';
                  var markup = '<div><img src="'+repo.head+'" style="width:30px;height:30px;"/>[id:'+repo.id+'] '+repo.nickname+'</div>';
                  return $(markup);
    			},
		});
	});	
	</script>
	
</block>